<template>
  <div class="launch" ref="launch" v-show="baseValue">
    <img class="l-logo" src="/static/loading.png" alt>
    <div class="l-ad">
      <img :src="baseLaunch|https" alt>
    </div>
    <!-- <div class="l-ad">
      <img :src="baseLaunch|https" alt="">
    </div>
    <div class="l-logo flex-center">
      <img src="/static/loading.png" alt="">
    </div>-->
    <!-- <div class="l-close" @click.stop.prevent="close">
      <span>{{txt}}</span>
    </div>-->
  </div>
</template>
<script>
// import { BaseValue } from '../common/api/base'
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      // logo: '//files.eyee.com/mcdn/static/img/launch_logo.png', // require('../assets/img/launch_logo.png')
      txt: "跳过",
      timer: {}
    };
  },
  computed: {
    ...mapGetters({ baseValue: "baseValue" }),
    baseLaunch() {
      let bv = this.baseValue;
      return (bv.configs && bv.configs.launchurl) || "";
    }
  },
  mounted() {
    // this.initShare()

    // if (!this.baseValue.configs) this.$store.dispatch('setBaseValue')
    // if (!(this.baseValue && this.baseValue.launchurl)) {
    //   this.BaseValue()
    // }

    // 启动页预加载首页数据
    this.$store.dispatch("setHomeGather");
    this.timer = setTimeout(() => { this.countDown() }, 1000)
  },
  methods: {
    close() {
      clearTimeout(this.timer);
      this.$router.replace("/");
    },
    countDown(i = 2) {
      i--;
      this.txt = i + " 秒";
      if (i === 0) {
        this.close();
        return false;
      }
      this.timer = setTimeout(() => {
        this.countDown(i);
      }, 1200);
    }
    // ,
    // BaseValue() {
    //   BaseValue().then((res) => {
    //     if (res) { this.$store.dispatch('setBaseValue', res) }
    //   }).catch(e => { console.error('基础数据加载失败', e) })
    // }
  },
  beforeDestroy() {
    clearTimeout(this.timer);
  }
};
</script>
